<?php
session_start();
set_include_path(dirname(__FILE__) . "/sdk/");
include_once('weibooauth.php');

function get_aurl($app_key, $app_secret, $identity, $passwd, $app_id, $user_id) {
    $o = new WeiboOAuth($app_key, $app_secret);

    $keys = $o->getRequestToken();
    $_SESSION['keys'] = $keys;
    $aurl = $o->getAuthorizeURL($keys['oauth_token'], false, $_SERVER['SCRIPT_URI'] . "http://192.168.1.201/taras-ui/manual_auth.php?identity={$identity}&passwd={$passwd}&app_id={$app_id}&user_id={$user_id}&app_key={$app_key}&app_secret={$app_secret}");
    $keys_and_aurl = array(keys=>$keys, aurl=>$aurl);
    return $aurl;
}

function get_access_token($app_key, $app_secret, $oauth_verifier) {
    $o = new WeiboOAuth($app_key, $app_secret, $_SESSION['keys']['oauth_token'], $_SESSION['keys']['oauth_token_secret']);

    $access_token = $o->getAccessToken($_REQUEST['oauth_verifier']);
    return $access_token;
}
?>
